/*
 * @Author: chen haoxuan
 * @Date: 2021-05-22 22:36:56
 * @LastEditTime: 2021-05-22 22:55:43
 */
#include<iostream>
using namespace std;
class Complex
{
    public:
        Complex(){real=0;imag=0;}
        Complex(double r,double i):real(r),imag(i){}
        void display();
        double real;
        double imag;
};
// 两个复数相加 eg: 3+4i + 5+5i
Complex operator+(Complex &c1,Complex &c2)
{
    return Complex(c1.real+c2.real,c1.imag+c2.imag);
}
// 一个实数和复数相加 实数在前 3 + 5+5i
Complex operator+(int i,Complex &c1)
{
    return Complex(i+c1.real,c1.imag);
}
// 一个实数和负数相加 实数在后
Complex operator+(Complex &c1,int i)
{
    return Complex(i+c1.real,c1.imag);
}
void Complex::display()
{
    cout<<"("<<real<<","<<imag<<"i)"<<endl;
}
int main()
{   
    Complex operator+(int i,Complex &c1);
    Complex operator+(Complex &c1,int i);
    Complex c1(1,1),c2(2,2),c3,c4,c5;
    c3=c1+c2; c3.display();
    c4=1+c2;  c4.display();
    c5=c2+99; c5.display();
    system("pause");
    return 0;
}